/*
 * @Descripttion: 
 * @version: V1.0.0
 * @Author: LeonHe
 * @Date: 2021-05-28 12:12:57
 * @LastEditTime: 2021-05-29 14:45:11
 */
#include "main.h"
#include "arm_math.h"
#include "Foc.h"
#include "commonfilter.h"


extern uint16_t adcBuff[];

#define K_AD_TO_CURRENT   0.006083f   //K = 3.3/4096*(15.1/10)/0.2    A    *1.51(电阻分压)
#define K_AD_TO_CURRENT_Q15   199   //K = (3.3/4096*(15.1/10)/0.2)*0x8000    A    *1.51(电阻分压)

avgLimitFilterQ15_EXPORT(elcAFilter, 12, 2000)
avgLimitFilterQ15_EXPORT(elcBFilter, 12, 2000)

void elcCurrentUpdate(q15_t* Ia, q15_t* Ib)
{
    *Ia = avgLimitFilterQ15(&elcAFilter, (adcBuff[0] - focCalbSt.CurrentOffset[0])*K_AD_TO_CURRENT_Q15);
    *Ib = avgLimitFilterQ15(&elcBFilter, (adcBuff[1] - focCalbSt.CurrentOffset[1])*K_AD_TO_CURRENT_Q15);

    return;
}
